package com.iwhalecloud.bss.kite.cucc.service.util;

import com.iwhalecloud.bss.kite.common.util.KiteObjectUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.dataservice.cache.DcPublicCache;
import com.iwhalecloud.bss.kite.dataservice.cache.OfferCache;
import com.iwhalecloud.bss.kite.dataservice.entity.DcPublic;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteSceneInst;
import com.ztesoft.bss.common.util.SpringUtil;

public class KiteDcPublicUtils {

    /**
     * 是否收入归集集团
     * @param sceneInstId
     * @return
     */
    public static boolean isCollectionGroup(String sceneInstId) {
        IQuerySceneInstService querySceneInstService = SpringUtil.getBean(IQuerySceneInstService.class);
        KiteSceneInst kiteSceneInst = querySceneInstService.getSceneInst(sceneInstId);
        String cateId = DcPublicCache.getCodea("20210223001", "CATE_ID");
        String rootInstId = kiteSceneInst.getRootInstId();
        String offerId = querySceneInstService.getOfferInst(kiteSceneInst.getCustId(), rootInstId).getOfferId();
        String objId = OfferCache.get(offerId).getAttrValue("cateId");
        if (KiteStringUtils.equals(objId, cateId)) {
            return true;
        }
        return false;
    }
    
    /**
     * 判断产品是否需要生成属性组实例ID
     * @param sceneInstId
     * @param prodInstId
     * @return
     */
    public static boolean isGenerateAttrGroupInstId(String sceneInstId, String prodInstId) {
        IQuerySceneInstService querySceneInstService = SpringUtil.getBean(IQuerySceneInstService.class);
        KiteSceneInst kiteSceneInst = querySceneInstService.getSceneInst(sceneInstId);
        KiteProdInst prodInst = querySceneInstService.getProdInst(kiteSceneInst.getCustId(), prodInstId);
        DcPublic dcPublic = DcPublicCache.get("20210507001", prodInst.getSpecId());
        if (!KiteObjectUtils.isEmpty(dcPublic)) {
            return true;
        }
        return false;
    }
}
